<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
{#    {{ username }}  通过键获取值#}
{#{{ Person.username }}#}
 {#列表{{ Persons.0 }} 获取键的一个值#}

{#判断#}
{#{% if age < 18 %}#}
{#    <p>你还是未成年,不能进入网吧</p>#}
{#{% elif age == 18 %}#}
{#    <p>你刚满,可进入</p>#}
{#{% else %}#}
{#    <p>你已经成年</p>#}
{#{% endif %}#}

{#{% if '孙悟空' in Persons %}#}
{#    <p>孙悟空在待命</p>#}
{#{% else %}#}
{#    <p>孙悟空在睡觉</p>#}
{##}
{#{% endif %}#}

{#循环遍历#}
{#<ul>#}
{#    {% for books in book %}#}
{#        <li>{{ books }}</li>#}
{##}
{#    {% endfor %}#}
{#</ul>#}

{##倒序reversed#}

{#<ul>#}
{#    {% for books in book reversed %}  #}
{#        <li>{{ books }}</li>#}
{##}
{#    {% endfor %}#}
{#</ul>#}
{#遍历所有键keys#}
{#<ul>#}
{#    {% for perpons in perpon.keys %}#}
{#        <li>{{ perpons }}</li>#}
{##}
{#    {% endfor %}#}
{##}
{#    #}
{#</ul>#}
{##}
{#</body>#}
{##}
{#遍历所有值values#}
{#<ul>#}
{#    {% for perpons in perpon.values %}#}
{#        <li>{{ perpons }}</li>#}
{##}
{#    {% endfor %}#}
{#</ul>#}


{#遍历所有元组#}
{#<ul>#}
{#    {% for key,vlaues in perpon.items %}#}
{#        <li>{{ key }} : {{ vlaues }}</li>#}
{##}
{#    {% endfor %}#}
{#</ul>#}

{#    <table>#}
{#        <thead>#}
{#            <tr>#}
{#                <td>书名</td>#}
{#                <td>作者</td>#}
{#                <td>价格</td>#}
{#            </tr>#}
{##}
{#            <tbody>#}
{##}
{#                    {% for book in books %}#}
{#                        <tr>#}
{#                            <td>{{ book.name }}</td>#}
{#                            <td>{{ book.author }}</td>#}
{#                            <td>{{ book.pricr }}</td>#}
{#                        </tr>#}
{##}
{#                    {% endfor %}#}
{##}
{#            </tbody>#}
{#        </thead>#}
{#    </table>#}

加序号forloop.counter
    <table>
        <thead>
            <tr>
                <td>序号</td>
                <td>书名</td>
                <td>作者</td>
                <td>价格</td>

            </tr>

            <tbody>

                    {% for book in books %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
{#                            <td>{{ forloop.counter0 }}</td>从0开始#}
                            <td>{{ book.name }}</td>
                            <td>{{ book.author }}</td>
                            <td>{{ book.pricr }}</td>
                        </tr>

                    {% endfor %}

            </tbody>
        </thead>
    </table>

empty用法
<ul>
    {% for comment  in comments %}
        <li>{{ comment }}</li>
    {% empty %}
        <li>没有任何评论</li>
    {% endfor %}

</ul>


</body>


</html>